package com.sxf.controller.interceptor;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.cache.CacheManager;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import com.sxf.common.tools.WPConstants;
import com.sxf.domain.viewbean.UserVO;
import com.sxf.web.WebHelp;

public class SessionInterceptor extends HandlerInterceptorAdapter {
	@Resource(name = "memCacheManager")
	private CacheManager cm;

	@Override
	public boolean preHandle(HttpServletRequest request,
			HttpServletResponse response, Object handler) throws Exception {
		UserVO user = WebHelp.getSessionUser(request, response, cm);
		request.setAttribute(WPConstants.LOGIN_USER, user);			
		return super.preHandle(request, response, handler);
	}

	@Override
	public void postHandle(HttpServletRequest request,
			HttpServletResponse response, Object handler,
			ModelAndView modelAndView) throws Exception {
		// TODO Auto-generated method stub
		super.postHandle(request, response, handler, modelAndView);
	}
}
